package web.common.internal.jdo.mapper;

import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;

/**
 * @author Jin Zheng
 * @since 2021-12-13
 */
public class SqlTimestampRowMapper implements RowMapper<Timestamp> {
	public SqlTimestampRowMapper() {
	}

	@Override
	public Timestamp mapRow(ResultSet rs, int row) throws SQLException {
		var meta = rs.getMetaData();
		if (meta.getColumnCount() < RowMapperFactory.ONE) {
			return null;
		}
		return rs.getTimestamp(RowMapperFactory.ONE);
	}
}
